package com.ai.robot;

import com.ai.helper.HelpService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *  运作机器人（语音）
 *
 * @author houwenpeng
 */
@Service
public class RobotService {


    @Autowired
    private HelpService helpController;

    @Autowired
    private RealRobotControl realRobotControl;

    /**
     * 处理并执行命令
     */
    public void execute(String command) {
        try {

            processCommand(command);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     *  处理命令并执行机器人动作
     * @param command
     */
    private  void processCommand(String command) {
        if (command == null) {
            System.out.println("无法识别语音");
            return;
        }
        command = command.toLowerCase();

        System.out.println("待下发指令集"+command);

        /*if (command.contains("前进")) {
            moveForward();
        } else if (command.contains("后退")) {
            moveBackward();
        } else if (command.contains("左转")) {
            turnLeft();
        } else if (command.contains("右转")) {
            turnRight();
        } else if (command.contains("停止")) {
            stop();
        } else {
            System.out.println("无法理解该命令: " + command);
        }*/
    }


    /**
     * 模拟机器人的动作
     */
    private  void moveForward() {

        //realRobotControl.moveForward();

        System.out.println("赛逼格机器人前进了...");
    }

    private  void moveBackward() {

        //realRobotControl.moveBackward();

        System.out.println("赛逼格机器人后退了...");

    }

    private  void turnLeft() {

        //realRobotControl.turnLeft();

        System.out.println("赛逼格机器人左转了...");

    }

    private  void turnRight() {

        //realRobotControl.turnRight();

        System.out.println("赛逼格机器人右转了...");

    }

    private  void stop() {

        //realRobotControl.stop();

        System.out.println("赛逼格机器人停止了...");
    }

}
